//
//  TiXianViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2017/11/15.
//  Copyright © 2017年 李 佳伟. All rights reserved.
//

#import "TiXianViewController.h"
#import "JTCSM.h"
#import "GetInfoClass.h"
#import "MyDoubleLabelView.h"
#import "ChoiceBankInfoView.h"
#import "TiXianInfoViewController.h"
static CGFloat backViewHeight = 100;
static CGFloat space = 20;
static CGFloat top = 20;
static CGFloat btnspace = 40;
static CGFloat btnHeight = 50;
@interface TiXianViewController ()
{
    NSString *total_price;
    UITextField *mytextfield;
}
@property (nonatomic,strong) MyDoubleLabelView *headerView;
@property (nonatomic,strong) ChoiceBankInfoView *choiceView;
@end

@implementation TiXianViewController


- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[GetInfoClass shareSingle] getinfo];
    
    [GetInfoClass shareSingle].myblock = ^(UserInfoModel *Model) {
      
        [self.headerView setvalueWithModel:@{KDoubleLabelTitle:@"可提现金额（元）",KDoubleLabelContent:[NSString stringWithFormat:@"%.2f",[Model.money floatValue]]}];
        [self.headerView setFrame:CGRectMake(0, (backViewHeight-self.headerView.frame.size.height)/2, KCONTROLLERWith, self.headerView.frame.size.height)];
        NSString *title = [Model.bank_card substringFromIndex:Model.bank_card.length-4];
        [self.choiceView setTitle:Model.bank_name content:[NSString stringWithFormat:@"尾号%@储蓄号",title]];

    };
    
}

- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)MingXin{
    TiXianInfoViewController *Vc = [[TiXianInfoViewController alloc]init];
    Vc.nameTitle = @"提现明细";
    [self.navigationController pushViewController:Vc animated:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.hidden = NO;
    [df isRemoveTarbar:YES];
    leftBarButtonItems_rightBarButtonItems *leftbtn = KCUSTOMNAVIGSTION_ALLOC;
    self.navigationItem.leftBarButtonItem = [leftbtn setBarButtonItemsImageName:@"fanhui.png" frame:KLeftBarButtonItemFrame_image target:self SEL:@selector(gotBack)];
    self.navigationItem.rightBarButtonItem = [leftbtn setBarButtonItemsTitle:@"明细" frame:CGRectMake(0, 0, 50, 44) target:self SEL:@selector(MingXin)];
    [self layoutSubview];
}
- (void)layoutSubview{
    
    UIView * backeview = [[UIView alloc]initWithFrame:CGRectMake(0, KagainChangeHeight , KCONTROLLERHeight, backViewHeight)];
    backeview.backgroundColor = RGBACOLOR(227, 72, 40, 1);
    [self.view addSubview:backeview];
    
    self.headerView = [[MyDoubleLabelView alloc]initWithFrame:CGRectMake(0, 0, KCONTROLLERWith, 0) titleFontsize:25 titlecolor:[UIColor whiteColor] contentFontsize:35 contentcolor:[UIColor whiteColor]];
    [backeview addSubview:self.headerView];
    
    UILabel *titleLabel = [UILabel initWithFrame:CGRectMake(space, KVIEW_Y(backeview)+top, KCONTROLLERWith-2*space, 30) text:@"提现金额" font:18 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, 1) backgroundColor:nil];
    [self.view addSubview:titleLabel];
    
    mytextfield = [UITextField initWithframe:CGRectMake(space, KVIEW_Y(titleLabel)+top, KCONTROLLERWith/2-space, 40) backgrandColor:nil placeholder:@"请输入提款金额" textAlignment:NSTextAlignmentLeft font:20 texcolor:RGBACOLOR(89, 89, 89, 1)];
    [self.view addSubview:mytextfield];
    [mytextfield addTarget:self  action:@selector(valueChanged:)  forControlEvents:UIControlEventAllEditingEvents];
    

    UILabel *btnLabel = [UILabel initWithFrame:CGRectMake(0, KVIEW_Y(titleLabel)+top, KCONTROLLERWith-2*space, 30) text:@"全部提现" font:16 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(227, 72, 40, 1) backgroundColor:nil];
    [self.view addSubview:btnLabel];
    CGRect rect = [df labelHeightWithContent:btnLabel.text height:30 font:20];
    btnLabel.frame = CGRectMake(KCONTROLLERWith-space-rect.size.width, KVIEW_Y(titleLabel)+top+5, rect.size.width, 30);
    
    [df lineViewWithHeightofTop:KVIEW_Y(mytextfield)+10 superView:self.view spacing:space color:RGBACOLOR(241, 241, 241, 1) lineHeight:1];
    
    UILabel *tishiLabel = [UILabel initWithFrame:CGRectMake(space, KVIEW_Y(mytextfield)+top, KCONTROLLERWith-2*space, 30) text:@"2小时到账" font:14 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(227, 72, 40, 1) backgroundColor:nil];
    [self.view addSubview:tishiLabel];
    
    self.choiceView = [[ChoiceBankInfoView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(tishiLabel)+top, KCONTROLLERWith-2*space, 70)];
    [self.choiceView setTitle:@"工商银行" content:@"尾号1805储蓄号"];
    [self.view addSubview:self.choiceView];
    
    [df lineViewWithHeightofTop:KVIEW_Y(self.choiceView)+10 superView:self.view spacing:space color:RGBACOLOR(241, 241, 241, 1) lineHeight:1];
    
    UIButton *LoginBtn =[[UIButton alloc] initWithFrame:CGRectMake(btnspace, KVIEW_Y(self.choiceView)+top , (KCONTROLLERWith-2*btnspace), btnHeight)];
    LoginBtn.backgroundColor =RGBACOLOR(227, 68, 40, 1);
    [LoginBtn setTitle:@"确认提现" forState:UIControlStateNormal];
    [LoginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [LoginBtn addTarget:self action:@selector(gotoMainV) forControlEvents:UIControlEventTouchUpInside];
    LoginBtn.tag = 10002;
    [self.view addSubview:LoginBtn];
    [df layerWithView:LoginBtn radius:btnHeight/2 width:0 color:nil];
}

#pragma mark 监听textfield 的变化
- (void)valueChanged:(UITextField *)textfield{
    total_price = textfield.text;
}

- (void)gotoMainV{
    LoadData *request = [[LoadData alloc]init];
    [request loadDataPostAsynchronousWithURL:KURLPOSTHeadr(@"UserCash/create") withDict:@{@"token":KTokenString,@"total_price":total_price==nil?@"":total_price} superView:nil isAddtag:YES Block:^(id result) {
        
        NSString *isreturn = [NSString stringWithFormat:@"%@",[result objectForKey:@"status"]];
        if ([isreturn isEqualToString:@"1"]) {
            mytextfield.text = @"";
            
        }
        
        
    }];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
